home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-01-17 | 2.9 KB | 101 lines | [TEXT/PJMM] |
- program Zkrolly;
- uses
- {$ifc UNDEFINED THINK_PASCAL}
- Types, QuickDraw, Fonts, Windows, Dialogs, OSUtils, Memory, {}
- {$endc}
- SAT, sXprite, sZprite;
-
- var
- ignoresp, zp: SpritePtr;
- zWind: WindowPtr;
- r: Rect;
-
- const
- scrollSizeH = 200;
- scrollSizeV = 150;
-
- function IsOptionPressed: Boolean;
- var
- km: KeyMap;
- begin
- GetKeys(km);
- IsOptionPressed := km[58];
- end;
-
- function Zyncho: Boolean;
- var
- where, dest: Rect;
- begin
- where.topLeft := zp^.position;
- where.left := where.left - scrollSizeH div 2;
- where.top := where.top - scrollSizeV div 2;
- if where.left < 0 then
- where.left := 0;
- if where.top < 0 then
- where.top := 0;
- if where.left + scrollSizeH > gSAT.offSizeH then
- where.left := gSAT.offSizeH - scrollSizeH;
- if where.top + scrollSizeV > gSAT.offSizeV then
- where.top := gSAT.offSizeV - scrollSizeV;
- where.bottom := where.top + scrollSizeV;
- where.right := where.left + scrollSizeH;
- SetRect(dest, 0, 0, scrollSizeH, scrollSizeV);
-
- CopyBits(gSAT.offScreen.port^.portBits, gSAT.wind.port^.portBits, where, dest, srcCopy, nil);
-
- {SATCopyBitsToScreen is obsolete - CopyBits is at least as fast for large areas anyway.}
- {For scrolling games, we must use other methods for improving the frame rate, like interlacing.}
-
- {SATCopyBitsToScreen(gSAT.offScreen, where, dest, IsOptionPressed);}
- {Note that there's hardly any speed difference between fast and safe mode when copying areas this big!}
-
- Zyncho := true; {Tell SAT not to draw on-screen: we do that ourselves!}
- end;
-
- procedure SetupZwind;
- var
- zr: Rect;
- wrld: SysEnvRec;
- begin
- {Since SAT hasn't been initialized yet, we can't use gSAT.colorFlag but have to check environs ourselves.}
- if noErr <> SysEnvirons(1, wrld) then
- ; {ignore errors}
- SetRect(zr, 20, 30, 20 + scrollSizeH, 30 + scrollSizeV);
- if wrld.hasColorQD then
- Zwind := NewCWindow(nil, zr, '', false, plainDBox, WindowPtr(-1), false, 0)
- else
- Zwind := NewWindow(nil, zr, '', false, plainDBox, WindowPtr(-1), false, 0);
- end;
-
- begin
- {In case this isn't Think Pascal we have to make the standard inits ourselves.}
- {$IFC UNDEFINED THINK_PASCAL}
- SATInitToolbox;
- {$ENDC}
-
- SetupZwind;
-
- SetRect(r, 0, 0, 510, 340);
- SATCustomInit(128, 129, r, zwind, nil, false, false, false, true, false);
- InitXprite;
- InitZprite;
- ShowWindow(gSAT.wind.port);
- SelectWindow(gSAT.wind.port);
- SATInstallSynch(@Zyncho);
- zp := SATNewSprite(0, 90, 70, @SetupZprite);
- ignoresp := SATNewSprite(0, 120, 100, @SetupXprite);
- ignoresp := SATNewSprite(0, 200, 160, @SetupXprite);
- SATSetPortScreen;
- repeat
- SATRun(IsOptionPressed);
- until Button;
-
- {WARNING! It seems like we mess up the current device somewhere. Probably a bug in SAT}
- {(where the device setting isn't perfect yet). Let's set port and device to something nice}
- {and safe!}
- SetPort(gSAT.wind.port);
- if gSAT.colorFlag then
- SetGDevice(GetMainDevice);
- { Finally, make sure we dispose of the sound channel. }
- SATSoundShutup;
- end.